package com.ruoyi.his.service.impl;

import java.util.Collections;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.his.mapper.NewHisPrescriptionMapper;
import com.ruoyi.his.domain.NewHisPrescription;
import com.ruoyi.his.service.INewHisPrescriptionService;

/**
 * 处方药品Service业务层处理
 *
 * @author vvjh
 * @date 2025-04-02
 */
@Service
public class NewHisPrescriptionServiceImpl implements INewHisPrescriptionService
{
    @Autowired
    private NewHisPrescriptionMapper newHisPrescriptionMapper;

    /**
     * 查询处方药品
     *
     * @param prescriptionId 处方药品主键
     * @return 处方药品
     */
    @Override
    public NewHisPrescription selectNewHisPrescriptionByPrescriptionId(Long prescriptionId)
    {
        return newHisPrescriptionMapper.selectNewHisPrescriptionByPrescriptionId(prescriptionId);
    }

    /**
     * 查询处方药品列表
     *
     * @param newHisPrescription 处方药品
     * @return 处方药品
     */
    @Override
    public List<NewHisPrescription> selectNewHisPrescriptionList(NewHisPrescription newHisPrescription)
    {
        return newHisPrescriptionMapper.selectNewHisPrescriptionList(newHisPrescription);
    }

    /**
     * 新增处方药品
     *
     * @param newHisPrescription 处方药品
     * @return 结果
     */
    @Override
    public int insertNewHisPrescription(NewHisPrescription newHisPrescription)
    {
        newHisPrescription.setCreateTime(DateUtils.getNowDate());
        return newHisPrescriptionMapper.insertNewHisPrescription(newHisPrescription);
    }

    /**
     * 修改处方药品
     *
     * @param newHisPrescription 处方药品
     * @return 结果
     */
    @Override
    public int updateNewHisPrescription(NewHisPrescription newHisPrescription)
    {
        newHisPrescription.setUpdateTime(DateUtils.getNowDate());
        return newHisPrescriptionMapper.updateNewHisPrescription(newHisPrescription);
    }

    /**
     * 批量删除处方药品
     *
     * @param prescriptionIds 需要删除的处方药品主键
     * @return 结果
     */
    @Override
    public int deleteNewHisPrescriptionByPrescriptionIds(Long[] prescriptionIds)
    {
        return newHisPrescriptionMapper.deleteNewHisPrescriptionByPrescriptionIds(prescriptionIds);
    }

    /**
     * 删除处方药品信息
     *
     * @param prescriptionId 处方药品主键
     * @return 结果
     */
    @Override
    public int deleteNewHisPrescriptionByPrescriptionId(Long prescriptionId)
    {
        return newHisPrescriptionMapper.deleteNewHisPrescriptionByPrescriptionId(prescriptionId);
    }

    @Override
    public List<NewHisPrescription> selectNewHisPrescriptionListByTreatId(String treatId) {
        return newHisPrescriptionMapper.selectNewHisPrescriptionListByTreatId(treatId);
    }
}
